package main

import (
	"context"
	"fmt"
	//"runtime"
	"time"
)

func main() {
	queue := []int{1,2,3,4}
	queue = queue[1:]
	fmt.Println(queue[0])
	fmt.Println(queue)

	//fmt.Println(job())
	//for i := 0; i < 50; i++ {
	//	go func() {
	//		job()
	//	}()
	//}
	////fmt.Println(runtime.NumGoroutine())
	//for {
	//	time.Sleep(time.Second * 2)
	//	fmt.Println(runtime.NumGoroutine())
	//
	//}
}

func job() error {
	ctx, _ := context.WithTimeout(context.Background(), time.Second)
	a := make(chan struct{})
	go func() {
		time.Sleep(time.Millisecond * 500)
		a <- struct{}{} //阻塞
	}()

	select {
	case <-a:
		return nil
	case <-ctx.Done():
		return fmt.Errorf("超时了")
	}
}
